﻿using System;
using System.Diagnostics;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Drawing;
using LowLevelGraphics;
using LowLevelGraphics.Forms;
using System.Windows.Forms;

namespace ImageRecognition2.Action
{
    /// <summary>
    /// 
    /// </summary>
    public class ActionParameterByteArray : AbstractCommand
    {
        private PictureBox m_PictureBox = null;
        private Delegate m_Delegate = null;

        /// <summary>
        /// Initializes a new instance of the <see cref="ActionParameterByteArray"/> class.
        /// </summary>
        /// <param name="_delegate">The _delegate.</param>
        /// <param name="_pictureBox">The _picture box.</param>
        public ActionParameterByteArray(Delegate _delegate, PictureBox _pictureBox)
        {
            m_PictureBox = _pictureBox;
            m_Delegate = _delegate;
        }

        /// <summary>
        /// Runs the specified sender.
        /// </summary>
        /// <param name="sender">The sender.</param>
        /// <param name="e">The <see cref="System.EventArgs"/> instance containing the event data.</param>
        public override void Run(object sender, EventArgs e)
        {
            FormParameter parameter = new FormParameter();
            if (parameter.ShowDialog() == DialogResult.OK)
            {
                Bitmap bitmap = (Bitmap)m_PictureBox.BackgroundImage;
                //UnsafeBitmap unsafeBitmap = m_Delegate.DynamicInvoke(bitmap, (byte[,])parameter.nValue) as UnsafeBitmap;
                //if (unsafeBitmap != null)
                //{
                //    unsafeBitmap.Dispose();
                //}
                //else
                //{
                //    Debug.WriteLine("UnsafeBitmap object expected, but was NULL");
                //}
            }
        }
    }
}
